package erfgame.core.path;

public class DefaultCostEstimator implements CostEstimator {
	
	private int minCost;
	
	public DefaultCostEstimator( int minCost ) {
		this.minCost = minCost;
	}

	public int estimate(int gxFrom, int gyFrom, int gIndexFrom, int gxTo, int gyTo, int gIndexTo) {
		int cFrom = gyFrom + 2 * gxFrom;
		if( (cFrom & 1) == 0 ) {
			cFrom++;
		}
		int cTo = gyTo - 2 * gxTo;
		if( (cTo & 1) == 0 ) {
			cTo--;
		}
		//int gxIntersection = (cFrom - cTo) / 4;
		int gyIntersection = (cFrom + cTo) / 2;
		return (Math.abs( gyFrom - gyIntersection ) + Math.abs( gyTo - gyIntersection )) * minCost;
	}

}
